package com.ghsc.yigou.live.config

import com.google.gson.Gson
import com.tencent.mmkv.MMKV

/**
 * 项目：YiGouLive
 * 包名：com.ghsc.yigou.live
 * 创建时间：2023/7/31 10:59
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 * 缓存
 */
object UserManager {
    /**退出**/
    fun loginOut() {
        MMKV.defaultMMKV().removeValuesForKeys(
            arrayOf(
                SP_USER_INFO,
                USER_ID,
                USER_R_ID,
                SP_CONFIG,
                USER_NAME,
                USER_HEAD,
                APP_NOTIE,
                APP_UP_VERSION,
                SP_USER_INFO_IN,
                APP_TASK,
                APP_TASK_TIME,
                IM_COUNT

        )
        )
    }
    //融云系统未读消息数量
    private  const val IM_COUNT ="im_count"
    private const val SP_USER_INFO = "sp_user_info" //用户信息
    private const val SP_USER_INFO_IN = "sp_user_info_in" //用户信息
    private const val USER_HEAD = "userHead" //用户头像
    private const val USER_NAME = "userName" //用户昵称
    private const val SP_CONFIG = "sp_user_config" //配置
    private const val APP_NOTIE = "Notice" //公告 一天一次
    //用户信息
    private const val APP_IS_FIRST = "IS_FIRST" //是否第一次打开,显示协议
    private const val USER_ID = "userID" //用户id
    private const val USER_R_ID = "userRID" //用户rid
    private const val APP_UP_VERSION = "app_version" // 1天显示1次

    private const val APP_TASK = "task_live" //直播任务
    private const val APP_TASK_TIME = "task_live_time" //直播任务

    fun setIsFirst(name:String){
        MMKV.defaultMMKV().encode(APP_IS_FIRST, name ?: "")
    }
    fun getIsFirst(): String {
        return MMKV.defaultMMKV().decodeString(APP_IS_FIRST, "") ?: ""
    }

    fun setUserId(id:String){
        MMKV.defaultMMKV().encode(USER_ID, id ?: "")
    }
    fun getUserId(): String {
        return MMKV.defaultMMKV().decodeString(USER_ID, "") ?: ""
    }
    fun setUserName(name:String){
        MMKV.defaultMMKV().encode(USER_NAME, name ?: "")
    }
    fun getUserName(): String {
        return MMKV.defaultMMKV().decodeString(USER_NAME, "") ?: ""
    }
    fun setUserHead(head:String){
        MMKV.defaultMMKV().encode(USER_HEAD, head ?: "")
    }
    fun getUserHead(): String {
        return MMKV.defaultMMKV().decodeString(USER_HEAD, "") ?: ""
    }
    fun setUserRId(id:String){
        MMKV.defaultMMKV().encode(USER_R_ID, id ?: "")
    }
    fun getUserRId(): String {
        return MMKV.defaultMMKV().decodeString(USER_R_ID, "") ?: ""
    }
    fun setImCount(name:Int){
        MMKV.defaultMMKV().encode(IM_COUNT, name ?: 0)
    }
    fun getImCount(): Int {
        return MMKV.defaultMMKV().decodeInt(IM_COUNT, 0) ?: 0
    }
    fun setAppNotice(name:String){
        MMKV.defaultMMKV().encode(APP_NOTIE, name ?: "")
    }
    fun getAppNotice(): String {
        return MMKV.defaultMMKV().decodeString(APP_NOTIE, "") ?: ""
    }

    fun setAppVersionTime(time: String){
        MMKV.defaultMMKV().encode(APP_UP_VERSION, time ?: "")
    }
    fun getAppVersionTime(): String {
        return MMKV.defaultMMKV().decodeString(APP_UP_VERSION, "") ?: ""
    }


    fun setLiveTaskTime(time: Int){
        MMKV.defaultMMKV().encode(APP_TASK_TIME, time ?: 0)
    }
    fun getLiveTaskTime(): Int {
        return MMKV.defaultMMKV().decodeInt(APP_TASK_TIME, 0) ?: 0
    }





}